﻿/*
COPYRIGHT (C) 2011-2012 Raynald Messié

THIS FILE IS PART OF SCRUMPILOT.

SCRUMPILOT IS FREE SOFTWARE: YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF 
THE GNU LESSER GENERAL PUBLIC LICENSE VERSION v2.1 AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION.

SCRUMPILOT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY; WITHOUT
EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU LESSER
GENERAL PUBLIC LICENSE FOR MORE DETAILS.

YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE ALONG WITH SCRUMPILOT. 
IF NOT, SEE <HTTP://WWW.GNU.ORG/LICENSES/>.
*/


using System.Globalization;
using System.Web.Mvc;
using ScrumPilot.TFSHelpers;

namespace ScrumPilot.Helpers
{
    public class AsyncBaseController : AsyncController
    {
        #region Properties
        private TFSServices _tfs;

        protected TFSServices TFS
        {
            get
            {
                if (_tfs == null || _tfs.TfsServer == null || !_tfs.TfsServer.HasAuthenticated)
                {
                    if (Session != null && Session["TFSServer"] != null)
                    {
                        _tfs = (TFSServices)Session["TFSServer"];
                        if (_tfs == null || _tfs.TfsServer == null || !_tfs.TfsServer.HasAuthenticated)
                        {
                            // TryToConnect();
                            _tfs = null;
                        }
                    }
                }
                return _tfs;
            }
        }

      

        private CultureInfo _ci;

        protected CultureInfo CurrentCulture
        {
            get
            {
                if (_ci == null)
                    if (HttpContext.Request.UserLanguages != null)
                        _ci = new CultureInfo(HttpContext.Request.UserLanguages[0]);
                return _ci;
            }
        }

        #endregion
    }
}